package com.major.mytomcat.servlet;

import com.major.mytomcat.Request;
import com.major.mytomcat.Response;

public class IndexServlet implements Servlet {

    public IndexServlet() {
        init();
    }

    @Override
    public void init() {

    }

    @Override
    public void service(Request request, Response response) {

        System.out.println("这是首页");

        response.write("<h1>Hello Servlet!</h1>");

        /*OutputStream output = response.getOutput();
        try {
            output.write("<h1>Hello Servlet!</h1>".getBytes());
            output.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }*/
    }

    @Override
    public void destroy() {

    }
}
